#include "threadPool.hpp"
#include "Task.hpp"
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include"log.hpp"

int main()
{
    srand((unsigned long)time(nullptr) ^ getpid());
    threadPool<Task> *tp = new threadPool<Task>();
    tp->run();

    while (true)
    {
        int x = (rand() + getpid() ^ 102545) % 1000;
        int y = rand() % 1000;

        Task t(x, y, [](int x, int y) -> int
               { return x + y; });

        //std::cout << "制作任务完成: " << x << "+" << y << "=?" << std::endl;
        logMessage(DEBUG,"%s: %d+%d =?","制作任务完成",x,y);
        tp->pushTask(t);
        sleep(1);
    }

    return 0;
}